package com.yh.homestay.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yh.homestay.common.HomeStayResult;
import com.yh.homestay.dao.HomeStayOrderMapper;
import com.yh.homestay.pojo.HomeStayOrder;
import com.yh.homestay.service.HomeStayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HomeStayOrderServiceImpl implements HomeStayOrderService {

    @Autowired
    private HomeStayOrderMapper homeStayOrderMapper;

    @Override
    public HomeStayResult findAllOrder(Integer page, Integer limit, Integer orderType, Integer orderPayType, Long orderId) {
        Map map = new HashMap();
        map.put("orderType",orderType);
        map.put("orderPayType",orderPayType);
        map.put("orderId",orderId);
        PageHelper.startPage(page,limit);
        List<HomeStayOrder> homeStayOrders = homeStayOrderMapper.selectAllOrder(map);
        PageInfo info = new PageInfo(homeStayOrders);

        return new HomeStayResult(0,"ok",(int)info.getTotal(),info.getList());
    }
}
